/*   1:    */ package org.jetbrains.generate.tostring.view;
/*   2:    */ 
/*   3:    */

import com.intellij.openapi.project.Project;
import com.intellij.ui.IdeBorderFactory;
import com.intellij.ui.LanguageTextField;
import org.intellij.lang.regexp.RegExpLanguage;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.generate.tostring.config.Config;
import org.jetbrains.generate.tostring.config.DuplicationPolicy;
import org.jetbrains.generate.tostring.config.InsertWhere;
import org.jetbrains.generate.tostring.config.PolicyOptions;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/*   4:    */
/*   5:    */
/*   6:    */
/*   7:    */
/*   8:    */
/*   9:    */
/*  10:    */
/*  11:    */
/*  12:    */
/*  13:    */
/*  14:    */
/*  15:    */
/*  16:    */
/*  17:    */
/*  18:    */
/*  19:    */
/*  20:    */
/*  21:    */
/*  22:    */
/*  23:    */
/*  24:    */
/*  25:    */
/*  26:    */
/*  27:    */
/*  28:    */
/*  29:    */ 
/*  30:    */ public class ConfigUI
/*  31:    */   extends JPanel
/*  32:    */ {
/*  33: 40 */   private final JCheckBox a = new JCheckBox("Use fully qualified class name in code generation ($classname)");
/*  34: 41 */   private final JCheckBox b = new JCheckBox("Enable getters in code generation ($methods)");
/*  35: 42 */   private final JCheckBox c = new JCheckBox("Move caret to generated method");
/*  36:    */   private JRadioButton[] d;
/*  37:    */   private JRadioButton[] e;
/*  38: 47 */   private final JCheckBox f = new JCheckBox("Exclude constant fields");
/*  39: 48 */   private final JCheckBox g = new JCheckBox("Exclude enum fields");
/*  40: 49 */   private final JCheckBox h = new JCheckBox("Exclude static fields");
/*  41: 50 */   private final JCheckBox i = new JCheckBox("Exclude transient fields");
/*  42: 51 */   private final JCheckBox j = new JCheckBox("Exclude logger fields (Log4j, JDK Logging, Jakarta Commons Logging)");
/*  43:    */   private final LanguageTextField k;
/*  44:    */   private final LanguageTextField l;
/*  45:    */   private final LanguageTextField m;
/*  46:    */   private final LanguageTextField n;
/*  47: 56 */   private final JComboBox o = new JComboBox();
/*  48: 57 */   private final JCheckBox p = new JCheckBox("Sort elements");
/*  49:    */   
/*  50:    */   public ConfigUI(Config paramConfig, Project paramProject)
/*  51:    */   {
/*  52: 66 */     super(new BorderLayout());
/*  53: 67 */     this.k = new LanguageTextField(RegExpLanguage.INSTANCE, paramProject, paramConfig.getFilterFieldName());
/*  54: 68 */     this.l = new LanguageTextField(RegExpLanguage.INSTANCE, paramProject, paramConfig.getFilterFieldType());
/*  55: 69 */     this.m = new LanguageTextField(RegExpLanguage.INSTANCE, paramProject, paramConfig.getFilterMethodName());
/*  56: 70 */     this.n = new LanguageTextField(RegExpLanguage.INSTANCE, paramProject, paramConfig.getFilterMethodType());
/*  57: 71 */     a();
/*  58: 72 */     setConfig(paramConfig);
/*  59:    */   }
/*  60:    */   
/*  61:    */   private void a()
/*  62:    */   {
/*  63: 81 */     JPanel localJPanel = new JPanel(new BorderLayout());
/*  64: 82 */     localJPanel.add(b(), "West");
/*  65: 83 */     add(localJPanel, "North");
/*  66:    */   }
/*  67:    */   
/*  68:    */   private JPanel b()
/*  69:    */   {
/*  70: 92 */     GridBagConstraints localGridBagConstraints = new GridBagConstraints();
/*  71: 93 */     JPanel localJPanel1 = new JPanel(new GridBagLayout());
/*  72:    */     
/*  73:    */ 
/*  74: 96 */     JPanel localJPanel2 = new JPanel();
/*  75: 97 */     localJPanel2.setLayout(new BoxLayout(localJPanel2, 1));
/*  76: 98 */     localJPanel2.setBorder(IdeBorderFactory.createTitledBorder("Settings", true));
/*  77: 99 */     Box localBox = Box.createHorizontalBox();
/*  78:100 */     localBox.add(this.a);
/*  79:101 */     localBox.add(Box.createHorizontalGlue());
/*  80:102 */     localJPanel2.add(localBox);
/*  81:103 */     localBox = Box.createHorizontalBox();
/*  82:104 */     localBox.add(this.b);
/*  83:105 */     localBox.add(Box.createHorizontalGlue());
/*  84:106 */     localJPanel2.add(localBox);
/*  85:107 */     localBox = Box.createHorizontalBox();
/*  86:108 */     localBox.add(this.c);
/*  87:109 */     localBox.add(Box.createHorizontalGlue());
/*  88:110 */     localJPanel2.add(localBox);
/*  89:111 */     localBox = Box.createHorizontalBox();
/*  90:112 */     localBox.add(this.p);
/*  91:113 */     this.p.addActionListener(new OnSortElements(null));
/*  92:114 */     localBox.add(Box.createHorizontalStrut(3));
/*  93:115 */     localBox.add(this.o);
/*  94:116 */     localJPanel2.add(localBox);
/*  95:117 */     this.o.addItem("Ascending");
/*  96:118 */     this.o.addItem("Descending");
/*  97:119 */     localGridBagConstraints.gridwidth = 0;
/*  98:120 */     localGridBagConstraints.fill = 1;
/*  99:121 */     localGridBagConstraints.gridx = 0;
/* 100:122 */     localGridBagConstraints.gridy = 0;
/* 101:123 */     localGridBagConstraints.insets.left = 5;
/* 102:124 */     localGridBagConstraints.insets.right = 5;
/* 103:125 */     localJPanel1.add(localJPanel2, localGridBagConstraints);
/* 104:    */     
/* 105:    */ 
/* 106:128 */     DuplicationPolicy[] arrayOfDuplicationPolicy = PolicyOptions.getConflictOptions();
/* 107:129 */     this.d = new JRadioButton[arrayOfDuplicationPolicy.length];
/* 108:130 */     ButtonGroup localButtonGroup1 = new ButtonGroup();
/* 109:131 */     for (int i1 = 0; i1 < arrayOfDuplicationPolicy.length; i1++)
/* 110:    */     {
/* 111:132 */       this.d[i1] = new JRadioButton(new ConflictResolutionOptionAction(arrayOfDuplicationPolicy[i1]));
/* 112:133 */       localButtonGroup1.add(this.d[i1]);
/* 113:    */     }
/* 114:135 */     localJPanel2 = new JPanel();
/* 115:136 */     localJPanel2.setLayout(new BoxLayout(localJPanel2, 1));
/* 116:137 */     localJPanel2.setBorder(IdeBorderFactory.createTitledBorder("When method already exists", true));
/* 117:138 */     for (Component localComponent : this.d) {
/* 118:139 */       localJPanel2.add(localComponent);
/* 119:    */     }
/* 120:141 */     localGridBagConstraints.gridx = 0;
/* 121:142 */     localGridBagConstraints.gridy = 1;
/* 122:143 */     localJPanel1.add(localJPanel2, localGridBagConstraints);
/* 123:    */     
/* 124:    */ 
/* 125:146 */     ??? = PolicyOptions.getNewMethodOptions();
/* 126:147 */     this.e = new JRadioButton[???.length];
/* 127:148 */     ButtonGroup localButtonGroup2 = new ButtonGroup();
/* 128:149 */     for (??? = 0; ??? < ???.length; ???++)
/* 129:    */     {
/* 130:150 */       this.e[???] = new JRadioButton(new InsertNewMethodOptionAction(???[???]));
/* 131:151 */       localButtonGroup2.add(this.e[???]);
/* 132:    */     }
/* 133:153 */     localJPanel2 = new JPanel();
/* 134:154 */     localJPanel2.setLayout(new BoxLayout(localJPanel2, 1));
/* 135:155 */     localJPanel2.setBorder(IdeBorderFactory.createTitledBorder("Where to insert?", true));
/* 136:156 */     for (JRadioButton localJRadioButton : this.e) {
/* 137:157 */       localJPanel2.add(localJRadioButton);
/* 138:    */     }
/* 139:159 */     localGridBagConstraints.gridx = 0;
/* 140:160 */     localGridBagConstraints.gridy = 2;
/* 141:161 */     localJPanel1.add(localJPanel2, localGridBagConstraints);
/* 142:    */     
/* 143:    */ 
/* 144:164 */     localJPanel2 = new JPanel();
/* 145:165 */     localJPanel2.setLayout(new BoxLayout(localJPanel2, 1));
/* 146:166 */     localJPanel2.setBorder(IdeBorderFactory.createTitledBorder("Exclude", true));
/* 147:167 */     localBox = Box.createHorizontalBox();
/* 148:168 */     localBox.add(this.f);
/* 149:169 */     localBox.add(Box.createHorizontalGlue());
/* 150:170 */     localJPanel2.add(localBox);
/* 151:171 */     localBox = Box.createHorizontalBox();
/* 152:172 */     localBox.add(this.h);
/* 153:173 */     localBox.add(Box.createHorizontalGlue());
/* 154:174 */     localJPanel2.add(localBox);
/* 155:175 */     localBox = Box.createHorizontalBox();
/* 156:176 */     localBox.add(this.i);
/* 157:177 */     localBox.add(Box.createHorizontalGlue());
/* 158:178 */     localJPanel2.add(localBox);
/* 159:179 */     localBox = Box.createHorizontalBox();
/* 160:180 */     localBox.add(this.g);
/* 161:181 */     localBox.add(Box.createHorizontalGlue());
/* 162:182 */     localJPanel2.add(localBox);
/* 163:183 */     localBox = Box.createHorizontalBox();
/* 164:184 */     localBox.add(this.j);
/* 165:185 */     localBox.add(Box.createHorizontalGlue());
/* 166:186 */     localJPanel2.add(localBox);
/* 167:187 */     localBox = Box.createHorizontalBox();
/* 168:188 */     localBox.add(new JLabel("Exclude fields by name (reg exp)"));
/* 169:189 */     localBox.add(Box.createHorizontalStrut(3));
/* 170:190 */     localBox.add(this.k);
/* 171:191 */     this.k.setMinimumSize(new Dimension(100, 20));
/* 172:192 */     localJPanel2.add(localBox);
/* 173:193 */     localBox = Box.createHorizontalBox();
/* 174:194 */     localBox.add(new JLabel("Exclude fields by type name (reg exp)"));
/* 175:195 */     localBox.add(Box.createHorizontalStrut(3));
/* 176:196 */     localBox.add(this.l);
/* 177:197 */     this.l.setMinimumSize(new Dimension(100, 20));
/* 178:198 */     localJPanel2.add(localBox);
/* 179:199 */     localBox = Box.createHorizontalBox();
/* 180:200 */     localBox.add(new JLabel("Exclude methods by name (reg exp)"));
/* 181:201 */     localBox.add(Box.createHorizontalStrut(3));
/* 182:202 */     localBox.add(this.m);
/* 183:203 */     this.m.setMinimumSize(new Dimension(100, 20));
/* 184:204 */     localJPanel2.add(localBox);
/* 185:205 */     localBox = Box.createHorizontalBox();
/* 186:206 */     localBox.add(new JLabel("Exclude methods by return type name (reg exp)"));
/* 187:207 */     localBox.add(Box.createHorizontalStrut(3));
/* 188:208 */     localBox.add(this.n);
/* 189:209 */     this.n.setMinimumSize(new Dimension(100, 20));
/* 190:210 */     localJPanel2.add(localBox);
/* 191:211 */     localGridBagConstraints.gridx = 0;
/* 192:212 */     localGridBagConstraints.gridy = 3;
/* 193:213 */     localJPanel1.add(localJPanel2, localGridBagConstraints);
/* 194:    */     
/* 195:215 */     return localJPanel1;
/* 196:    */   }
/* 197:    */   
/* 198:    */   public final void setConfig(Config paramConfig)
/* 199:    */   {
/* 200:224 */     this.a.setSelected(paramConfig.isUseFullyQualifiedName());
/* 201:225 */     DuplicationPolicy localDuplicationPolicy = paramConfig.getReplaceDialogInitialOption();
/* 202:226 */     for (Object localObject2 : this.d) {
/* 203:227 */       if (localObject2.getText().equals(localDuplicationPolicy.toString())) {
/* 204:228 */         localObject2.setSelected(true);
/* 205:    */       }
/* 206:    */     }
/* 207:231 */     ??? = paramConfig.getInsertNewMethodInitialOption();
/* 208:232 */     for (JRadioButton localJRadioButton : this.e) {
/* 209:233 */       if (localJRadioButton.getText().equals(((InsertWhere)???).toString())) {
/* 210:234 */         localJRadioButton.setSelected(true);
/* 211:    */       }
/* 212:    */     }
/* 213:239 */     this.f.setSelected(paramConfig.isFilterConstantField());
/* 214:240 */     this.g.setSelected(paramConfig.isFilterEnumField());
/* 215:241 */     this.h.setSelected(paramConfig.isFilterStaticModifier());
/* 216:242 */     this.i.setSelected(paramConfig.isFilterTransientModifier());
/* 217:243 */     this.j.setSelected(paramConfig.isFilterLoggers());
/* 218:    */     
/* 219:245 */     this.b.setSelected(paramConfig.isEnableMethods());
/* 220:246 */     this.c.setSelected(paramConfig.isJumpToMethod());
/* 221:    */     
/* 222:248 */     this.p.setSelected(paramConfig.getSortElements() != 0);
/* 223:249 */     this.o.setEnabled(this.p.isSelected());
/* 224:250 */     if ((paramConfig.getSortElements() == 0) || (paramConfig.getSortElements() == 1)) {
/* 225:251 */       this.o.setSelectedIndex(0);
/* 226:252 */     } else if (paramConfig.getSortElements() == 2) {
/* 227:253 */       this.o.setSelectedIndex(1);
/* 228:    */     }
/* 229:    */   }
/* 230:    */   
/* 231:    */   @Nullable
/* 232:    */   private static String a(String paramString)
/* 233:    */   {
/* 234:259 */     if ((paramString != null) && (paramString.length() == 0)) {
/* 235:259 */       return null;
/* 236:    */     }
/* 237:260 */     return paramString;
/* 238:    */   }
/* 239:    */   
/* 240:    */   public final Config getConfig()
/* 241:    */   {
/* 242:269 */     Config localConfig = new Config();
/* 243:    */     
/* 244:271 */     localConfig.setUseFullyQualifiedName(this.a.isSelected());
/* 245:    */     JRadioButton localJRadioButton;
/* 246:273 */     for (localJRadioButton : this.d) {
/* 247:274 */       if (localJRadioButton.isSelected()) {
/* 248:275 */         localConfig.setReplaceDialogInitialOption(((ConflictResolutionOptionAction)localJRadioButton.getAction()).option);
/* 249:    */       }
/* 250:    */     }
/* 251:279 */     for (localJRadioButton : this.e) {
/* 252:280 */       if (localJRadioButton.isSelected()) {
/* 253:281 */         localConfig.setInsertNewMethodInitialOption(((InsertNewMethodOptionAction)localJRadioButton.getAction()).option);
/* 254:    */       }
/* 255:    */     }
/* 256:285 */     localConfig.setFilterConstantField(this.f.isSelected());
/* 257:286 */     localConfig.setFilterEnumField(this.g.isSelected());
/* 258:287 */     localConfig.setFilterTransientModifier(this.i.isSelected());
/* 259:288 */     localConfig.setFilterLoggers(this.j.isSelected());
/* 260:289 */     localConfig.setFilterStaticModifier(this.h.isSelected());
/* 261:290 */     localConfig.setFilterFieldName(a(this.k.getText()));
/* 262:291 */     localConfig.setFilterFieldType(a(this.l.getText()));
/* 263:292 */     localConfig.setFilterMethodName(a(this.m.getText()));
/* 264:293 */     localConfig.setFilterMethodType(a(this.n.getText()));
/* 265:    */     
/* 266:295 */     localConfig.setEnableMethods(this.b.isSelected());
/* 267:296 */     localConfig.setJumpToMethod(this.c.isSelected());
/* 268:298 */     if (!this.p.isSelected()) {
/* 269:299 */       localConfig.setSortElements(0);
/* 270:300 */     } else if (this.o.getSelectedIndex() == 0) {
/* 271:301 */       localConfig.setSortElements(1);
/* 272:    */     } else {
/* 273:303 */       localConfig.setSortElements(2);
/* 274:    */     }
/* 275:306 */     return localConfig;
/* 276:    */   }
/* 277:    */   
/* 278:    */   private static class ConflictResolutionOptionAction
/* 279:    */     extends AbstractAction
/* 280:    */   {
/* 281:    */     public final DuplicationPolicy option;
/* 282:    */     
/* 283:    */     ConflictResolutionOptionAction(DuplicationPolicy paramDuplicationPolicy)
/* 284:    */     {
/* 285:316 */       super();
/* 286:317 */       this.option = paramDuplicationPolicy;
/* 287:    */     }
/* 288:    */     
/* 289:    */     public void actionPerformed(ActionEvent paramActionEvent) {}
/* 290:    */   }
/* 291:    */   
/* 292:    */   private static class InsertNewMethodOptionAction
/* 293:    */     extends AbstractAction
/* 294:    */   {
/* 295:    */     public final InsertWhere option;
/* 296:    */     
/* 297:    */     InsertNewMethodOptionAction(InsertWhere paramInsertWhere)
/* 298:    */     {
/* 299:331 */       super();
/* 300:332 */       this.option = paramInsertWhere;
/* 301:    */     }
/* 302:    */     
/* 303:    */     public void actionPerformed(ActionEvent paramActionEvent) {}
/* 304:    */   }
/* 305:    */   
/* 306:    */   private class OnSortElements
/* 307:    */     implements ActionListener
/* 308:    */   {
/* 309:    */     private OnSortElements() {}
/* 310:    */     
/* 311:    */     public void actionPerformed(ActionEvent paramActionEvent)
/* 312:    */     {
/* 313:345 */       ConfigUI.this.o.setEnabled(ConfigUI.this.p.isSelected());
/* 314:    */     }
/* 315:    */   }
/* 316:    */ }



/* Location:           E:\idea\

 * Qualified Name:     org.jetbrains.generate.tostring.view.ConfigUI

 * JD-Core Version:    0.7.0.1

 */